import 'package:intl/intl.dart';

class DateFormatUtils {
  static String dateTimeToStr(DateTime? date, {String format = 'dd-MM-yyyy'}) {
    if (date == null) {
      return "";
    }
    var formatter = DateFormat(format);
    return formatter.format(date);
  }

  static DateTime? strToDateTime(String? dateStr,
      {String format = 'yyyy-MM-dd'}) {
    if (dateStr == null) {
      return null;
    }
    var formatter = DateFormat(format);
    return formatter.parse(dateStr);
  }
}
